import Http from "../utils/http"
import cache from "../enum/cache"

class User {
  static async login(userInfo) {
    const res =  await Http.request({
      url: '/app/login',
      data: {
        password: userInfo.password,
        username: userInfo.username
      },
      method : 'POST'
    })
    // 获取令牌
    wx.setStorageSync(cache.TOKEN, res.token)
    return res
  }
  // 登出
  static async logout() {
    const res = await Http.request({
      url: '/logout',
      method : 'POST'
    })
    // 清空
    wx.clearStorageSync()
    return res
  }
}

export default User